home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2008 February / PCWFEB08.iso / Software / Resources / Utilities / Partition Logic 0.68 / partlogic-0.68.iso / system / headers / sys / disk.h < prev    next >
Encoding:
C/C++ Source or Header  |  2007-05-10  |  4.5 KB  |  134 lines

  1. // 
  2. //  Visopsys
  3. //  Copyright (C) 1998-2007 J. Andrew McLaughlin
  4. //  
  5. //  This library is free software; you can redistribute it and/or modify it
  6. //  under the terms of the GNU Lesser General Public License as published by
  7. //  the Free Software Foundation; either version 2.1 of the License, or (at
  8. //  your option) any later version.
  9. //
  10. //  This library is distributed in the hope that it will be useful, but
  11. //  WITHOUT ANY WARRANTY; without even the implied warranty of
  12. //  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser
  13. //  General Public License for more details.
  14. //
  15. //  You should have received a copy of the GNU Lesser General Public License
  16. //  along with this library; if not, write to the Free Software Foundation,
  17. //  Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  18. //
  19. //  disk.h
  20. //
  21.  
  22. // This file contains definitions and structures for using and manipulating
  23. // disk in Visopsys.
  24.  
  25. #if !defined(_DISK_H)
  26.  
  27. #include <sys/file.h>
  28.  
  29. #define DISK_MAXDEVICES               32
  30. #define DISK_MAX_NAMELENGTH           16
  31. #define DISK_MAX_PARTITIONS           16
  32. #define DISK_MAX_PRIMARY_PARTITIONS   4
  33. #define DISK_MAX_CACHE                1048576 // 1 Meg
  34. #define FSTYPE_MAX_NAMELENGTH         32
  35.  
  36. // Extended partition types
  37. #define PARTITION_TYPEID_EXTD         0x05
  38. #define PARTITION_TYPEID_EXTD_LBA     0x0F
  39. #define PARTITION_TYPEID_EXTD_LINUX   0x85
  40. #define PARTITION_TYPEID_IS_EXTD(x)    \
  41.   ((x == PARTITION_TYPEID_EXTD)     || \
  42.    (x == PARTITION_TYPEID_EXTD_LBA) || \
  43.    (x == PARTITION_TYPEID_EXTD_LINUX))
  44. #define PARTITION_TYPEID_IS_HIDDEN(x)                          \
  45.   ((x == 0x11) || (x == 0x14) || (x == 0x16) || (x == 0x17) || \
  46.    (x == 0x1B) || (x == 0x1C) || (x == 0x1E) || (x == 0x93))
  47. #define PARTITION_TYPEID_IS_HIDEABLE(x)                        \
  48.   ((x == 0x01) || (x == 0x04) || (x == 0x06) || (x == 0x07) || \
  49.    (x == 0x0B) || (x == 0x0C) || (x == 0x0E) || (x == 0x83))
  50.  
  51. // Flags for supported filesystem operations on a partition
  52. #define FS_OP_FORMAT                  0x01
  53. #define FS_OP_CLOBBER                 0x02
  54. #define FS_OP_CHECK                   0x04
  55. #define FS_OP_DEFRAG                  0x08
  56. #define FS_OP_STAT                    0x10
  57. #define FS_OP_RESIZECONST             0x20
  58. #define FS_OP_RESIZE                  0x40
  59.  
  60. // Flags to describe what type of disk is described by a disk structure
  61. #define DISKTYPE_LOGICAL              0x20000000
  62. #define DISKTYPE_PHYSICAL             0x10000000
  63. #define DISKTYPE_PRIMARY              0x01000000
  64. #define DISKTYPE_LOGICALPHYSICAL      (DISKTYPE_PHYSICAL | DISKTYPE_LOGICAL)
  65. #define DISKTYPE_FIXED                0x00200000
  66. #define DISKTYPE_REMOVABLE            0x00100000
  67. #define DISKTYPE_FIXEDREMOVABLE       (DISKTYPE_FIXED | DISKTYPE_REMOVABLE)
  68. #define DISKTYPE_FLOPPY               0x00000100
  69. #define DISKTYPE_SCSICDROM            0x00000020
  70. #define DISKTYPE_IDECDROM             0x00000010
  71. #define DISKTYPE_CDROM                (DISKTYPE_SCSICDROM | DISKTYPE_IDECDROM)
  72. #define DISKTYPE_FLASHDISK            0x00000004
  73. #define DISKTYPE_SCSIDISK             0x00000002
  74. #define DISKTYPE_IDEDISK              0x00000001
  75. #define DISKTYPE_HARDDISK             (DISKTYPE_FLASHDISK | \
  76.                                        DISKTYPE_SCSIDISK | DISKTYPE_IDEDISK)
  77.  
  78. // Flags to describe the current state of the disk
  79. #define DISKFLAG_NOCACHE              0x10
  80. #define DISKFLAG_READONLY             0x08
  81. #define DISKFLAG_MOTORON              0x04
  82. #define DISKFLAG_DOORLOCKED           0x02
  83. #define DISKFLAG_DOOROPEN             0x01
  84. #define DISKFLAG_USERSETTABLE         (DISKFLAG_NOCACHE | DISKFLAG_READONLY)
  85.  
  86. // This structure is used to describe a known partition type
  87. typedef struct {
  88.   unsigned char code;
  89.   const char description[FSTYPE_MAX_NAMELENGTH];
  90.  
  91. } partitionType;   
  92.  
  93. typedef struct {
  94.   char name[DISK_MAX_NAMELENGTH];
  95.   int deviceNumber;
  96.   unsigned type;
  97.   unsigned flags;
  98.   partitionType partType;
  99.   char fsType[FSTYPE_MAX_NAMELENGTH];
  100.   unsigned opFlags;
  101.  
  102.   unsigned heads;
  103.   unsigned cylinders;
  104.   unsigned sectorsPerCylinder;
  105.   unsigned sectorSize;
  106.  
  107.   unsigned startSector;
  108.   unsigned numSectors;
  109.  
  110.   // Filesystem related
  111.   unsigned blockSize;
  112.   unsigned freeBytes;
  113.   unsigned minSectors;  // for
  114.   unsigned maxSectors;  // resize
  115.   int mounted;
  116.   char mountPoint[MAX_PATH_LENGTH];
  117.   int readOnly;
  118.  
  119. } disk;
  120.  
  121. typedef struct {
  122.   // Throughput measurement.
  123.   unsigned readTime;
  124.   unsigned readKbytes;
  125.   unsigned writeTime;
  126.   unsigned writeKbytes;
  127.  
  128. } diskStats;
  129.  
  130. #define CYLSECTS(d) (d->heads * d->sectorsPerCylinder)
  131.  
  132. #define _DISK_H
  133. #endif
  134.